<?php

namespace App\Http\Requests\Admin;

use App\Http\Requests\BaseRequest;
use Illuminate\Foundation\Http\FormRequest;

class AddSysUserRequest extends BaseRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'username' => [
                'required'
            ],

            'name' => [
                'required'
            ],
            'mobile' => [
                'required',
                'regex:/^1[3456789]\d{9}$/',
                'digits:11',
                'unique:sys_users,mobile'
            ],
            'email' => [
                'required',
                'email',
                'unique:sys_users,email'
            ]
        ];
    }

    public function messages()
    {
        return [
            'username.required' => '请输入用户帐号',
            'name.required' => '请输入用户姓名',
            'mobile.required' => '请输入手机号',
            'mobile.regex' => '手机号格式错误',
            'mobile.digits' => '手机号由11位数字组成',
            'mobile.unique' => '该手机号已被使用',
            'email.required' => '请输入电子邮箱',
            'email.email' => '电子邮箱格式错误',
            'email.unique' => '该电子邮箱已被使用'
        ];
    }
}
